﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace INTROSE
{
    public partial class View_Users_Tabbed : Form
    {
        string name, position, viewName;
        public View_Users_Tabbed(string name, string position)
        {
            InitializeComponent();
            this.name = name;
            this.position = position;
            FillData();
        }

        private void btnMainMenu_Click(object sender, EventArgs e)
        {
            this.Close();
            MenuExecutive menu = new MenuExecutive(name, position);
            menu.Show();
        }
        void FillData()
        {
            // 1
            // Open connection
            using (SqlConnection c = new SqlConnection("Data Source = .\\SQLEXPRESS; Database = Introse; Integrated Security = True"))
            {
                c.Open();
                // 2
                // Create new DataAdapter
                using (SqlDataAdapter a = new SqlDataAdapter("SELECT * FROM users", c))
                {
                    // 3
                    // Use DataAdapter to fill DataTable
                    DataTable t = new DataTable();
                    a.Fill(t);
                    // 4
                    // Render data onto the screen
                    dataGridView1.DataSource = t;
                }
            }
        }

        private void View_Users_Tabbed_Load(object sender, EventArgs e)
        {

        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            viewName = txtEmpName.Text;
            this.Close();
            View_User view = new View_User(name, position, viewName);
            view.Show();
        }
    }
}
